Repository navigation
stages/authenticator_validate: reject malformed WebAuthn assertions as an invalid device - #27479
Merged
BeryJu merged 1 commit intoDec 1, 2026
Conversation
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27479 +/- ##
==========================================
+ Coverage 93.74% 93.76% +0.01%
==========================================
Files 1262 1262
Lines 91440 91465 +25
Branches 5752 5752
==========================================
+ Hits 85724 85759 +35
+ Misses 5630 5620 -10
Partials 86 86
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
BeryJu
approved these changes
Dec 1, 2026
…s an invalid device validate_challenge_webauthn() only caught InvalidJSONStructure from parse_authentication_credential_json(). py_webauthn raises InvalidAuthenticationResponse when a credential field isn't valid base64url, and a bare ValueError (binascii.Error) when userHandle isn't, so such an assertion, for example a forged passwordless login, failed the flow with the error screen and a system_exception event instead of a validation error. Catch WebAuthnException and ValueError around the parse, as the WebAuthn setup stage does around verify_registration_response(). This covers both callers: the authenticator validation stage and the identification stage's passkey login.
BeryJu
force-pushed
the
stages/authenticator_validate-malformed-webauthn
branch
from
December 1, 2026 17:29
6dc3be0 to
c7bfeb6
Compare
This was referenced Dec 1, 2026
Contributor
|
🍒 Cherry-pick to |
Contributor
|
🍒 Cherry-pick to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details
What does this PR change?
validate_challenge_webauthn()only caughtInvalidJSONStructurefromparse_authentication_credential_json(). When a credential field isn't valid base64url, py_webauthn raisesInvalidAuthenticationResponseinstead. Forresponse.userHandleit doesn't wrap the error at all, so a bareValueError(binascii.Error) comes through. Both reached the flow executor, which answered with the flow error and created asystem_exceptionevent.It now catches
WebAuthnExceptionandValueErroraround the parse and answers "Invalid device", as it already did forInvalidJSONStructure. The WebAuthn setup stage catches the same pair aroundverify_registration_response(). This covers both callers: the authenticator validation stage and the identification stage's passkey login.Why is this change needed?
Anyone can post an assertion to a passwordless flow without logging in first. A malformed one is a client error, but it currently creates a
system_exceptionevent.How was this tested?
authentik/stages/authenticator_validate/tests/test_webauthn.py, which fail without the fix:test_validate_challenge_malformed:validate_challenge_webauthn()with arawId,clientDataJSONorauthenticatorDatathat isn't base64url, asignaturethat isn't ASCII, and auserHandlethat isn't base64url or isn't ASCII. Each raises aValidationError, "Invalid device" with the codeinvalid.test_validate_challenge_malformed_userless: a passwordless flow gets a malformed assertion and answers with the stage's challenge and the "Invalid device" error.authentik/stages/authenticator_validate,authentik/stages/authenticator_webauthnandauthentik/stages/identification: 98 passed.Linked issues
Checklist
make all)make docs)